const sharp = require('sharp');
const path = require('path');

async function convertImage(inputPath) {
  try {
    const outputPath = inputPath.replace('.avif', '.png');
    await sharp(inputPath)
      .png()
      .toFile(outputPath);
    console.log(`转换成功: ${inputPath} -> ${outputPath}`);
  } catch (error) {
    console.error(`转换失败 ${inputPath}:`, error);
  }
}

async function main() {
  const imagesToConvert = [
    '../miniprogram/images/meals/lunch3.avif',
    '../miniprogram/images/meals/dinner3.avif'
  ];

  for (const imagePath of imagesToConvert) {
    await convertImage(imagePath);
  }
}

main().catch(console.error); 